function editProfile() {
    document.getElementById('personalInfoFields').disabled = false;
}

function populateUserInfo() {
    var who = JSON.parse(localStorage.getItem("loggedinUser"));
    var users = JSON.parse(localStorage.getItem("users"));

    //find the person who is logged in
    const user = users.find(u => u.email === who["email"]);
    document.getElementById("nameInput").value = user["name"];
    document.getElementById("schoolInput").value = user["school"];
    document.getElementById("cityInput").value = user["city"];
}
populateUserInfo();

function saveProfile() {
    var who = JSON.parse(localStorage.getItem("loggedinUser"));
    var users = JSON.parse(localStorage.getItem("users"));
    const user = users.find(u => u.email === who["email"]);
    user.name = document.getElementById('nameInput').value;
    user.city = document.getElementById('cityInput').value;
    user.school = document.getElementById('schoolInput').value;
    localStorage.setItem("loggedinUser", JSON.stringify(user));
    localStorage.setItem("users", JSON.stringify(users));
    document.getElementById('personalInfoFields').disabled = true;
    alert('User Data Saved');
}

